package com.asl.website.stat.domain;

import com.asl.website.common.Language;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 482944566@qq.com
 * @version 1.0
 * @date 2025-05-21
 */

public class NetWorkStatDTO {
    private List<StatItem> stats;
    private String language;

    // 构造方法
    public NetWorkStatDTO(List<BizNetworkStat> stats, String language) {
        this.language = language;
        this.stats = stats.stream()
                .map(stat -> new StatItem(stat, language))
                .collect(Collectors.toList());
    }

    // 内部静态类 - 单个统计项
    public static class StatItem {
        private String iconUrl;
        private String statValue;
        private String description;

        public StatItem(BizNetworkStat stat, String language) {
            this.iconUrl = stat.getIconUrl();
            this.statValue = stat.getStatValue();

            switch (Language.fromCode(language)) {
                case EN_US:
                    this.description = stat.getDescriptionEn();
                    break;
                case DE_DE:
                    this.description = stat.getDescriptionDe();
                    break;
                default: // 默认中文
                    this.description = stat.getDescriptionZh();
            }
        }

        // getters
        public String getIconUrl() {
            return iconUrl;
        }

        public String getStatValue() {
            return statValue;
        }

        public String getDescription() {
            return description;
        }
    }

    // getters
    public List<StatItem> getStats() {
        return stats;
    }

    public String getLanguage() {
        return language;
    }
}
